package fr.masterglr.website.googlr.model;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@SuppressWarnings("unused")
@Entity
@Table(name="Search")

public class Search implements Serializable {

	/**
	 * Generated Serial Version UID
	 */
	private static final long serialVersionUID = -8871180991956524734L;
	
	
	@Id
	@Column(name = "ID_SEARCH", nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;
	
	@Column(name = "DATE_SEARCH", nullable = false)
	@Temporal(TemporalType.DATE)
	private Date date;
	
	@Column(name = "TIME_SEARCH", nullable = false)
	private double time;
	
	@Column(name = "QUERY", length = 200, nullable = false)
	private String query;
	
	@Column(name = "COMMENTS", length = 8000, nullable = true)
	private String comments;

	@Column(name = "TIPS", length = 200, nullable = true)
	private String tips;
	
	@Column(name = "START_INDEX", nullable = false)
	private int startIndex;

	@Column(name = "END_INDEX", nullable = false)
	private int endIndex;

	@Column(name = "TOTAL_RESULTS", nullable = false)
	private int totalResults;
	
	@Column(name = "DOCUMENT_FILTERING", nullable = true)
	private boolean documentFiltering;
	
	@Column(name = "ESTIMATE_CORRECT", nullable = true)
	private boolean estimateCorrect;

	@OneToMany(mappedBy="search", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
	private Collection<Result> results;

	// constructeurs
	public Search() {
	}



	public Search(Date date, double time, String query, String comments, String tips, int startIndex, int endIndex, int totalResults, boolean documentFiltering, boolean estimateCorrect) {
		super();
		this.date = date;
		this.time = time;
		this.query = query;
		this.comments = comments;
		this.tips = tips;
		this.startIndex = startIndex;
		this.endIndex = endIndex;
		this.totalResults = totalResults;
		this.documentFiltering = documentFiltering;
		this.estimateCorrect = estimateCorrect;
	}



	/**
	 * @return Returns the comments.
	 */
	public String getComments() {
		return comments;
	}



	/**
	 * @param comments The comments to set.
	 */
	public void setComments(String comments) {
		this.comments = comments;
	}



	/**
	 * @return Returns the date.
	 */
	public Date getDate() {
		return date;
	}



	/**
	 * @param date The date to set.
	 */
	public void setDate(Date date) {
		this.date = date;
	}



	/**
	 * @return Returns the documentFiltering.
	 */
	public boolean isDocumentFiltering() {
		return documentFiltering;
	}



	/**
	 * @param documentFiltering The documentFiltering to set.
	 */
	public void setDocumentFiltering(boolean documentFiltering) {
		this.documentFiltering = documentFiltering;
	}



	/**
	 * @return Returns the endIndex.
	 */
	public int getEndIndex() {
		return endIndex;
	}



	/**
	 * @param endIndex The endIndex to set.
	 */
	public void setEndIndex(int endIndex) {
		this.endIndex = endIndex;
	}



	/**
	 * @return Returns the estimateCorrect.
	 */
	public boolean isEstimateCorrect() {
		return estimateCorrect;
	}



	/**
	 * @param estimateCorrect The estimateCorrect to set.
	 */
	public void setEstimateCorrect(boolean estimateCorrect) {
		this.estimateCorrect = estimateCorrect;
	}



	/**
	 * @return Returns the id.
	 */
	public Integer getId() {
		return id;
	}



	/**
	 * @param id The id to set.
	 */
	public void setId(Integer id) {
		this.id = id;
	}



	/**
	 * @return Returns the query.
	 */
	public String getQuery() {
		return query;
	}



	/**
	 * @param query The query to set.
	 */
	public void setQuery(String query) {
		this.query = query;
	}



	/**
	 * @return Returns the results.
	 */
	public Collection<Result> getResults() {
		return results;
	}



	/**
	 * @param results The results to set.
	 */
	public void setResults(Set<Result> results) {
		this.results = results;
	}



	/**
	 * @return Returns the startIndex.
	 */
	public int getStartIndex() {
		return startIndex;
	}



	/**
	 * @param startIndex The startIndex to set.
	 */
	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}



	/**
	 * @return Returns the time.
	 */
	public double getTime() {
		return time;
	}



	/**
	 * @param time The time to set.
	 */
	public void setTime(double time) {
		this.time = time;
	}



	/**
	 * @return Returns the tips.
	 */
	public String getTips() {
		return tips;
	}



	/**
	 * @param tips The tips to set.
	 */
	public void setTips(String tips) {
		this.tips = tips;
	}



	/**
	 * @return Returns the totalResults.
	 */
	public int getTotalResults() {
		return totalResults;
	}



	/**
	 * @param totalResults The totalResults to set.
	 */
	public void setTotalResults(int totalResults) {
		this.totalResults = totalResults;
	}



	/**
	 * @param results The results to set.
	 */
	public void setResults(Collection<Result> results) {
		this.results = results;
	}

}
